import {createRouter, createWebHistory} from 'vue-router'
import HomeView from '../views/HomeView.vue'
import LoginView from "@/views/LoginView.vue";
import NotFoundView from "@/views/NotFoundView.vue";
import LayoutView from "@/views/LayoutView.vue";
import UserView from "@/views/UserView.vue";
import RegisterView from "@/views/registerView.vue";
import forgetPasswordView from "@/views/forgetPasswordView.vue";
import forgetPasswordConfirmView from '@/views/forgetPasswordConfirmView.vue'
import UserProfileView from "@/views/UserProfileView.vue";
import AnnouncementView from "@/views/AnnouncementView.vue";
import ArticleView from "@/views/ArticleView.vue";
import CategoryView from "@/views/CategoryView.vue";
import AuditView from "@/views/AuditView.vue";
import BookView from "@/views/BookView.vue";
import LogView from "@/views/LogView.vue";

const router = createRouter({
    history: createWebHistory(import.meta.env.BASE_URL),
    routes: [
        {
            path: '/',
            component: LayoutView,
            children: [
                {
                    path: 'home',
                    name: 'home',
                    component: HomeView,
                    meta: {
                        title: '首页',
                        keepAlive: true
                    }
                },
                {
                    path: '/info/user',
                    name: 'user',
                    component: UserView,
                    meta: {
                        title: '用户管理',
                        keepAlive: true
                    }
                },
                {
                    path: '/info/announcement',
                    name: 'announcement',
                    component: AnnouncementView,
                    meta: {
                        title: '公告管理',
                        keepAlive: true
                    }
                },
                {
                    path: '/info/category',
                    name: 'category',
                    component: CategoryView,
                    meta: {
                        title: '文章分类',
                        keepAlive: true
                    }
                },
                {
                    path: '/info/article',
                    name: 'article',
                    component: ArticleView,
                    meta: {
                        title: '文章管理',
                        keepAlive: true
                    }
                },
                {
                    path: '/info/book',
                    name: 'book',
                    component: BookView,
                    meta: {
                        title: '图书管理',
                        keepAlive: true
                    }
                },
                {
                    path: '/profile',
                    name: 'profile',
                    component: UserProfileView,
                    meta: {
                        title: '个人信息',
                        keepAlive: true
                    }
                },
                {
                    path: '/audit',
                    name: 'audit',
                    component: AuditView,
                    meta: {
                        title: '审核管理',
                        keepAlive: true
                    }
                },

                {
                    path: '/log',
                    name: 'log',
                    component: LogView,
                    meta: {
                        title: '系统日志',
                        keepAlive: true
                    }
                }
            ]
        },
        {
            path: '/login',
            component: LoginView,
        },
        {
            path: '/register',
            component: RegisterView,
        },
        {
            path: '/forget-password',
            component: forgetPasswordView,
        },
        {
            path: '/forget-password-confirm',
            component: forgetPasswordConfirmView,
        }
        ,
        {
            path: '/user',
            component: UserView,
        },
        {

            path: '/:pathMatch(.*)*',
            name: 'NotFound',
            component: NotFoundView
        }
    ],
})

export default router
